﻿using System;

namespace smp.ButterflyCakes.Models.Data
{
    public class StageDataItem
    {
        public StageDataItem()
        {
            IsExisting = true;
        }

        public StageDataItem(Guid componentId, Stage stage, NextOrderStage previousStage)
        {
            Id = Guid.NewGuid();
            ComponentId = componentId;
            Title = stage.GetDescription();
            Created = DateTime.Now;
            Stage = stage;
            OrderId = previousStage.OrderId;
            PreviousStageId = previousStage.Id;
            Index = previousStage.Index + 1;
        }

        public StageDataItem(Guid orderId, Guid componentId, Stage stage, int index)
        {
            Id = Guid.NewGuid();
            ComponentId = componentId;
            Title = stage.GetDescription();
            Created = DateTime.Now;
            Stage = stage;
            OrderId = orderId;
            Index = index;
        }

        public StageDataItem(Guid orderId, Guid componentId, Stage stage, Guid? previousStageId, int index)
        {
            Id = Guid.NewGuid();
            ComponentId = componentId;
            Title = stage.GetDescription();
            Created = DateTime.Now;
            Stage = stage;
            OrderId = orderId;
            PreviousStageId = previousStageId;
            Index = index;
        }

        public StageDataItem(Guid orderId, Guid componentId, Stage stage, Guid? previousStageId, int index, string title)
        {
            Id = Guid.NewGuid();
            ComponentId = componentId;
            Title = title;
            Created = DateTime.Now;
            Stage = stage;
            OrderId = orderId;
            PreviousStageId = previousStageId;
            Index = index;
        }

        public Guid Id { get; set; }
        public Guid ComponentId { get; set; }
        public string Title { get; set; }
        public DateTime Created { get; set; }
        public Stage Stage { get; set; }
        public Guid OrderId { get; set; }
        public Guid? PreviousStageId { get; set; }
        public int Index { get; set; }
        public bool IsExisting { get; private set; }
    }
}
